package com.funny.stock.user.service;

import com.funny.stock.base.service.BaseCrudServiceV2;
import com.funny.stock.user.dao.pojo.SysUserDO;
import com.funny.stock.user.dao.repo.SysUserRepo;
import com.funny.stock.user.vo.SysUserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service;

/**
 * @Description  
 * @Author  pengl
 * @Date 2020-05-17 
 */

@Service
public class SysUserService extends BaseCrudServiceV2<SysUserVO,SysUserDO,Long> implements UserService{

	@Autowired
	SysUserRepo repository;

	protected JpaRepository<SysUserDO, Long> setupJpaRepository() {
		return repository;
	}

	@Override
	protected Class<SysUserDO> getDOClass() {
		return SysUserDO.class;
	}

	@Override
	protected Class<SysUserVO> getVOClass() {
		return SysUserVO.class;
	}

	@Override
	public SysUserVO findByLoginAccount(String loginAccount) {
		SysUserDO sysUserDO = repository.findByLoginAccount(loginAccount);
		return convertVO(sysUserDO);
	}

	@Override
	public SysUserVO findByUserId(Long userId) {
		SysUserDO sysUserDO = repository.findByUserId(userId);
		return convertVO(sysUserDO);
	}
}
